// pages/afflatus/common/filter-pop/index.js
Component({
  /**
   * 组件的属性列表
   */
  /***
   * 
   *  filterRows 
   *    
   * 
   * 
   * 
   * 
   * */ 
  properties: {
    filterShow:{
      type:Boolean,
      value:false,
      observer:function(){
        
      }
    },
    filterRows:{
       type:Array,
       value:[
         {
           isSingle:true,
           title:"年龄",
           dataList: [
             {
               text: '20'
             }, 
             {
               text: '30'
             },
             {
              text: '40'
             }
           ]
         },
         {
          isSingle:false,
          title:"测试1",
          dataList: [
            {
              text: '测试数据1'
            }, 
            {
              text: '测试数据2'
            },
            {
              text: '测试数据3'
            }
          ]
         }
       ],
       observer:function(newValue,oldValue){
          //  console.log(newValue)
       }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    top:wx.getMenuButtonBoundingClientRect().top + 7
  },
  observers:{
    "filterRows.dataList":function(newValue){
      //  console.log("***************:",newValue)
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {

    filterReSet(){
      this.data.filterRows.forEach(filterItem =>{
        filterItem.dataList.forEach(item =>{
            item.selected = false
        })
      })
      this.setData({
        filterRows:this.data.filterRows,
        filterShow:false
      })
      wx.nextTick(()=>{
         this.triggerEvent('reset',this.data.filterRows)
      })
    },
    filterConfirm(){
       this.setData({
         filterShow:false
       })
       this.triggerEvent('confirm',this.data.filterRows)
    },
    selectItem(e){
      let rowIndex = e.currentTarget.dataset.rowindex
      let dataList = e.detail
      this.data.filterRows[rowIndex].dataList = dataList
  
    },
    filterClose(){
       this.setData({
         filterShow:false
       })
    }
  }
})
